import { reqOrderList } from "../../api/order";
import { removeStorage, setStorage } from "../../utils/storage";

// pages/order/order.js
Page({

  data: {
    active:"all",
    allorder:[],
  },


  onLoad: function(options) {
    const active = options.active; // 获取传递的 id
    console.log(active)
    if (active) {
      this.setData({
        active:active
      })
    }
    this.LoadOrderList()
  },

  navigateToProfile:function(){
    wx.switchTab({
      url: '/pages/profile/profile',
    })
  },
  
  async LoadOrderList(){
    const config={
      'content-type': 'application/x-www-form-urlencoded'
    }

    const param = {
      orderStatus:this.data.active
    }

    const {data} = await reqOrderList(param,config);
    // console.log(data) 
    this.setData({
      order:data
    })
  },

  onShow(){
    this.LoadOrderList()
  },

  onchange(event){
    this.setData({
      active:event.detail.name
    })
    // console.log(this.data.active)
    this.LoadOrderList()
  },

})